package cn.qqncn.controller;


import cn.qqncn.email.EmailUtils;
import org.springframework.web.bind.annotation.*;

import javax.mail.MessagingException;
import javax.swing.*;
import java.security.GeneralSecurityException;

/**
 * @author zkw
 * @Description TODO
 * @createTime 2021年05月07日 16:37:00
 */
@RequestMapping("email")
@RestController
public class EmailController {

    /**
     * 发送邮件接口
     * @param content 邮件内容
     * @param email 收件人
     * @param from_date 胶囊埋下时间
     * @return
     */
    @PostMapping("/sendEmail")
    public String sendEmail(@RequestParam("content") String content,
                            @RequestParam("email") String email,
                            @RequestParam("from_date") String from_date) {
        EmailUtils emailUtils = new EmailUtils();
        try {
            emailUtils.senEmail(email, content,from_date);
        } catch (Exception e) {
            return "false";
        }
        return "true";
    }

}
